<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ taglib prefix="s" uri="/struts-tags"%>
    
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <title>My JSP 'login.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script type="text/javascript" src="${pageContext.request.contextPath}/editor/jquery/jquery-1.4.4.min.js"></script>
   <script type="text/javascript" src="${pageContext.request.contextPath}/editor/jquery/jquery.form.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/editor/jquery/jquery.cookie.js"></script>
 
 <script type="text/javascript">
 $(document).ready(function() {
	    if ($.cookie("rmbUser") == "true") {
	        $("#rmbUser").attr("checked", true);
	        $("#userName").val($.cookie("userName"));
	        $("#password").val($.cookie("passWord"));
	    }
	});

function login(){
	 var q = $("#userName").val();
	 var c = $("#password").val();
	 if ($("#rmbUser").attr("checked") == true) {
	        $.cookie("rmbUser", "true", { expires: 7 }); // 存储一个带7天期限的 cookie
	        $.cookie("userName",q, { expires: 7 }); // 存储一个带7天期限的 cookie
	        $.cookie("passWord",c, { expires: 7 }); // 存储一个带7天期限的 cookie
	    }
	    else {
	        $.cookie("rmbUser", "false", { expires: -1 });        // 删除 cookie
	        $.cookie("userName", '', { expires: -1 });
	        $.cookie("passWord", '', { expires: -1 });
	    }
	 $.ajax({
		   type: "POST",
		   url: "login.action",
		   data:{"name":q,"pwd":c},
		   beforeSend: function() {
				$(".deng").val("正在登录...");
				return true;
			},
			success: function(jsonObject) {
				if(jsonObject.isSUCCESS) {
					window.location.href='page_user_index.action';
				}else{
					$(".deng").val("登   录");
					$("#message").html("<font color='red'>用户名或密码错误！</font>");
				}
			}
		}); 
 }
 function zhuce(){
		window.location.href='page_user_regist.action';

 }
</script >
  </head>
  <body>
  <jsp:include page="top.jsp"></jsp:include>
  
    	用户名:<input type="text" id="userName"/><br/>
    	密码:<input type="password" id="password"/><br/>
    	<input type="checkbox" checked="true" name="chkRememberUsername" class="checkbox" id="rmbUser">
        <label for="rmbUser">记住用户名</label><a href="page_user_forpwd.action">找回密码</a>
    	<span id="message" float:left"></span>
    	<input type="button" value="登陆" class="deng" onclick="login()"/>
    	<input type="button" value="注册" onclick="zhuce()"/>
  </body>
</html>
